<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="layui/css/layui.css" />
<script type="text/javascript" src="layui/layui.js"></script>
</head>
<body>
	<form class="layui-form" onsubmit="false">
	<div class="layui-form-item" hidden="hidden">
			<label class="layui-form-label"><span style="color: red;">*</span>ID：</label>
			<div class="layui-input-inline" style="width: 350px">
				<input type="text" name="Bid" id="Bid" required
					lay-verify="required" placeholder="" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item" style="margin-top: 20px">
			<label class="layui-form-label"><span style="color: red;">*</span>名称：</label>
			<div class="layui-input-inline" style="width: 350px">
				<input type="text" name="Bname" id="Bname" required
					lay-verify="required" placeholder="" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">*</span>修改图片：</label>
			<div class="layui-input-inline" style="width: 350px">
			<button type="button" class="layui-btn" id="test1">
				<i class="layui-icon">&#xe67c;</i>上传图片
			</button>
			<img id="imgFace" style="width:120px;" src="" />
			<input style="width: 350px;" hidden="hidden" id="Burl" name="Burl" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">*</span>跳转地址：</label>
			<div class="layui-input-inline" style="width: 350px">
				<input type="text" name="BskipUrl" id="BskipUrl" required
					lay-verify="required" placeholder="" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-btn-container" style="text-align: center;">
				<button class="layui-btn" lay-submit lay-filter="formDemo">编辑</button>
			</div>
		</div>
	</form>

	<script>
		//Demo
		layui.use(['form','upload'], function() {
			var form = layui.form;
			var $ = layui.jquery;
			var upload = layui.upload;
			//执行实例
			var uploadInst = upload.render({
				elem : '#test1' //绑定元素
				,
				url : '/shoppingsix/upload?method=addUpload' //上传接口
				,
				done : function(res) {
					//上传完毕回调
					console.log(res);
					$("#Burl").val('upload/'+res.data);
					$("#imgFace").attr('src','/shoppingsix/houtai/upload/'+res.data);
				},
				error : function() {
					//请求异常回调
				}
			});
			//监听提交
			form.on('submit(formDemo)', function(data) {
				var d = data.field;//表单中的数据，定义一个对象来接收
				var url = '/shoppingsix/banner_update';
				$.post(url, d, function(data) {
					if (data.count > 0) {
						var index = parent.layer.getFrameIndex(window.name);//获取当前窗口的name
						parent.layer.close(index);//关闭窗口
					}
				}, "json");
				return false;
			});
		});
	</script>

</body>
</html>